<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>编辑全日健康</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <el-form :model="infoForm" label-width="90px" ref="editForm">
          <el-form-item label="学生姓名：">
            {{ detailOption ? (detailOption.student ? detailOption.student.name : '--') : '--' }}
          </el-form-item>
          <el-form-item label="检查日期：">
            <el-date-picker
                v-model="infoForm.day"
                type="date"
                :picker-options="pickerOptions1"
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
                size="small"
                class="w-140"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="健康状况：">
            <el-input
                type="textarea"
                placeholder="健康状况"
                v-model="infoForm.healthy"
                maxlength="100"
                show-word-limit
                rows="5"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="处理：" prop="num">
            <el-input
                type="textarea"
                placeholder="处理"
                v-model="infoForm.handle"
                maxlength="100"
                show-word-limit
                rows="5"
            >
            </el-input>
          </el-form-item>
        </el-form>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="closePOpup" size="small">取消</el-button>
        <el-button size="small" type="primary" @click="checkEditFn">确定并提交</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {yeartime} from "@/assets/js/common";
import {dayCheckEdit, dayCheckDetail} from "@/api/admin/ClassDynamics"

export default {
  props: ['visible', 'detailId'], // recruitmentType examine 审核
  components: {},
  data() {
    return {
      dialogVisible: false,
      infoForm: {
        student_id: '', //学生id
        day: yeartime(new Date()), // 检查日期
        healthy: '', // 健康状况
        handle: '' // 处理
      },
      tableHeight: 0,
      pickerOptions1: {
        disabledDate(time) {
          // return time.getTime() < Date.now()
        }
      },
      detailOption: null
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (!this.visible) {
        this.infoForm = {
          student_id: '', //学生id
          day: yeartime(new Date()), // 检查日期
          healthy: '', // 健康状况
          handle: '' // 处理
        }
        this.detailOption = null
      } else {
        this.getDetail()
      }
    }
  },
  created() {

  },
  methods: {
    getDetail() {
      dayCheckDetail({id: this.detailId}).then(res => {
            console.log('res===>:', res)
            this.infoForm.student_id = res.vo.student_id
            this.infoForm.day = res.vo.day
            this.infoForm.healthy = res.vo.healthy
            this.infoForm.handle = res.vo.handle
            this.detailOption = res.vo
          }
      )
    },
    checkEditFn() {
      if (!this.infoForm.day) {
        this.$message.error('选择检查日期');
        return
      }
      let data_ = JSON.parse(JSON.stringify(this.infoForm))
      data_.id = this.detailId
      dayCheckEdit(data_).then(res => {
        console.log('res:', res)
        this.$emit('InitFn')
        this.closePOpup()
      })
    },
// 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 500px;
  height: 520px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

</style>
